package com.etlmaster.executor.steps.datax;

import java.util.HashMap;
import java.util.Map;

import com.etlmaster.executor.JobPool;
import com.etlmaster.executor.Step;
import com.etlmaster.executor.StepMeta;
import com.etlmaster.executor.annotation.StepInstruction;


/**
 * @author Wugf
 * @date 2016-11-10
 */
@StepInstruction("hbasewriter")
public class HbaseWriterStep  extends Step{
	private HbaseWriterStepMeta meta;
	public HbaseWriterStep(StepMeta meta) {
		super(meta);
		this.meta=(HbaseWriterStepMeta) meta;
	}

	@Override
	protected int handle() {
		Map<String, String> data = new HashMap<String, String>();
		
		data.put("tableName",meta.getTableName());
		data.put("hbaseZookeeperHosts",meta.getHbaseZookeeperHosts());
		data.put("hbaseZookeeperPorts", meta.getHbaseZookeeperPorts());
		data.put("columns", meta.getColumns());
		data.put("rowKeyColumns", meta.getRowKeyColumns());
		data.put("concurrency", meta.getConcurrency());
		Map<String,String> rtnMap= DataxWriter.runDatax(this.hashCode(), "hbasewriter", JobPool.getVariable(meta.getSession_id()).get("readerjobconf").toString(), data);
		meta.getStepState().getReturnValue().put("logInfo", rtnMap.get("jobInfo"));
		return Integer.valueOf(rtnMap.get("status"));

	}

	@Override
	public boolean stop() {
		// TODO Auto-generated method stub
		return false;
	}

}
